﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using PMS.BusinessFacade;
using PMS.EntityManage;
using PMS.Common;
using PMS.EntityQuery;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using BusinessFacade;
using EntityManage;

public partial class Modules_System_Org_List : System.Web.UI.Page
{

    ISys_UserHandler userHandler = new Sys_UserManage();
    ISys_OrganizationHandler orgHandler = new Sys_OrganizationManage();
    ISys_OrganizationHandlerExt orgExtHandler = new Sys_OrganizationManageExt();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CheckPurviews())
        {
            Response.Redirect("~/Login.aspx");
        }
        if (!IsPostBack)
        {
            ViewState["OrderBy"] = "Id";
            ViewState["Accending"] = "asc";

            //dataBind(string.Empty, null);
            
        }
    }

    private bool CheckPurviews()
    {
        if (Session["UserPurviews"] != null)
        {
            string strPur = Session["UserPurviews"].ToString();
            if (strPur.Contains("202010"))
            {
                if (strPur.Contains("202011"))
                {
                    lbtnNew.Visible = true;
                }
                else
                {
                    lbtnNew.Visible = false;
                }
                if (strPur.Contains("202012"))
                {
                    lbtnMod.Visible = true;
                }
                else
                {
                    lbtnMod.Visible = false;
                }
                if (strPur.Contains("202013"))
                {
                    lbtnDel.Visible = true;
                }
                else
                {
                    lbtnDel.Visible = false;
                }
            }
            else
            {
                return false;
            }
            return true;
        }
        else
        {
            return false;
        }
    }

    /// <summary>
    /// 初始化用户信息表
    /// </summary>
    //private void dataBind(string whereClause, SqlParameter[] parms)
    //{
    //    try
    //    {
    //        SqlParameter[] parms2 = null;
    //        int counter = 0;
    //        DataTable dt = new DataTable();

    //        if (whereClause != string.Empty)
    //        {
    //            //dt = userHandler.GetSys_UserByPageList(whereClause, parms, ViewState["OrderBy"].ToString() + " " + ViewState["Accending"].ToString(), AspNetPager.StartRecordIndex - 1, AspNetPager.PageSize);
    //            dt = orgHandler.GetSys_OrganizationByPageList(whereClause, parms, ViewState["OrderBy"].ToString() + " " + ViewState["Accending"].ToString(), AspNetPager.StartRecordIndex - 1, AspNetPager.PageSize);
    //            whereClause = "1=1";
    //            ProcessParms(ref whereClause, ref parms2);
    //            counter = orgHandler.GetCounter(whereClause, parms2);
    //        }
    //        else
    //        {
    //            dt = orgHandler.GetSys_OrganizationByPageList(ViewState["OrderBy"].ToString() + " " + ViewState["Accending"].ToString(), AspNetPager.StartRecordIndex - 1, AspNetPager.PageSize);
    //            counter = orgHandler.GetCounter();
    //        }

    //        this.AspNetPager.RecordCount = counter;            
    //        gvOrgList.DataSource = dt;
    //        gvOrgList.DataBind();
    //    }
    //    catch(Exception ex)
    //    {
    //        Jscript.AlertInAjax("連接錯誤!", UpdatePanel1);
    //        return;
    //    }
    //}

    protected void btnSave_Click(object sender, EventArgs e)
    {
        
    }

}
